#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>

#define FOR(i,a,n) for(int i=a,_n(n);i<_n;++i)
#define REP(i,n) FOR(i,0,n)

const int INF = 1<<29;

using namespace std;

typedef long long lld;

int last[100010];

int GetDiviser(int pos,int x,int y)
{
    int ret = 0;
    for(int i=1;i*i<=x;++i) if(x%i==0)
    {
        if(last[i]<pos-y) ++ret;
        last[i] = pos;
        if(i*i==x) continue;
        int t = x/i;
        if(last[t]<pos-y) ++ret;
        last[t] = pos;
    }
    return ret;
}

int main()
{
    int n;
    while(cin>>n)
    {
        REP(i,100010) last[i] = -1;
        FOR(i,1,n+1)
        {
            int xi,yi;
            scanf("%d%d",&xi,&yi);
            printf("%d\n",GetDiviser(i,xi,yi));
        }
    }
    return 0;
}
